﻿module ChartForm

open System.Windows.Forms
open System.Windows.Forms.DataVisualization.Charting

type ChartForm (title)=
    inherit Form( Text=title )

    let chart = new Chart(Dock=DockStyle.Fill)
    let areaName = System.Guid.NewGuid().ToString()
    let area = new ChartArea(Name=areaName)
    do chart.ChartAreas.Add(area)
    do base.Controls.Add( chart )

    member this.AddChart ( xys : (float * float) seq, chartType )=
      let series = new Series()
      do series.ChartType <- chartType
      do xys |> Seq.iter (series.Points.AddXY >> ignore)
      do series.ChartArea <- areaName
      do chart.Series.Add( series )